$(function(){
	
		/*
if(user=='')
		{
			 $.ajax({ url: 'admin/loginbox.html', 
			          cache: false, 
					   success:function(data){
			 	           $("body").append(data);
			           }
			 });
		}
*/
	
})
function createDateGrid(columns,url,param,singleSelect,height)
	{
		var lastIndex;
	     $("#dataGrid").datagrid({
                        pagination: true,
						rownumbers:true,
						striped:true,
						pageList:[15,20,25,30],
						pageSize:15,
						showPageList:true,
						singleSelect:singleSelect,
						queryParams:param,
                        url: url,
                        columns: columns,
						onDblClickRow:function(index){
							  $('#dataGrid').datagrid('beginEdit', index);
							  $(".datagrid-editable-input").focus();
							  $(".datagrid-editable-input").blur(function(){
							      $('#dataGrid').datagrid('endEdit', index);
								  var getRowIndex=$("#dataGrid").datagrid("getSelected");
								  sort(getRowIndex.id,($(this).val()=="")?1:$(this).val());
							  });
				          }
			        });			
			        resize(height) ;
	}
	
//重设DataGrid
	function resize(height) 
	{
		
	   var width=$("body").width();
	   $("#dataGrid").datagrid("resize",{width:width,height:height});
	}
	//获得类别列表
	function categoryList(id,columnId,categoryId,callback)
	{
		if(categoryId==-2)
		{
			return false;
		}
	    $.getJSON("category!categoryForList.action",{"category.id":categoryId,"category.columnId":columnId},function(data){
			var option="<option value='-2'>选择类别</option>";
			for(var i=0;i<data.length;i++)
			{
				option+="<option value='"+data[i].id+"'>"+data[i].name+"</option>";
			}
			$("#"+id).html(option);
			if(callback!=undefined)
			{
				callback();
			}
			
		})	;
	}
//获得商家
function businessOption(id,callback)
{
	$.getJSON("business!businessOptionForJson.action",function(data){
			var option="<option value='-2'>选择类别</option>";
			for(var i=0;i<data.length;i++)
			{
				option+="<option value='"+data[i][0].id+"'>"+data[i][0].name+"</option>";
			}
			$("#"+id).html(option);
			if(callback!=undefined)
			{
				callback();
			}
			
		})	;
}
